package com.fang.shirotestnoredis.util;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {
    private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");

    //将String类型转为Date类型
    public static Date parseDate(String time){
        Date date = null;
        try {
            date = simpleDateFormat.parse(time);
        }catch (Exception e){
            e.printStackTrace();
        }
        return date;
    }

    //将Date类型转换为String类型
    public static String parseString(Date time){
        String date = null;
        try {
            date = simpleDateFormat.format(time);
        }catch (Exception e){
            e.printStackTrace();
        }
        return date;
    }

    //比较两个日期的大小
    public static boolean isOverTime(Date planEndTime){
        //与当前日期作比较
        long time = System.currentTimeMillis();
        long endTime = planEndTime.getTime();
        if(time > endTime){
            return false;
        }else {
            return true;
        }
    }

}
